package org.ziwei.paipan.biao;

import org.ziwei.paipan.var.DiZhi;

/**
 * 时系诸星表
 * 根据出生时辰，定时系诸星宫位
 */
public class ShiXiZhuXingBiao {
	
	/**
	 * 从戌宫起子时，逆数到生时的宫位排文昌星，从辰宫起子，顺数到生时的宫位安文曲星。
	 * 如卯时生人，则戌宫起子逆数到卯，文昌在未，辰宫起子顺数到卯，文曲在未。
	 */
	private static DiZhi[] wenChangBiao = {DiZhi.XU,DiZhi.YOU,DiZhi.SHEN,DiZhi.WEI,DiZhi.WU,DiZhi.SI,DiZhi.CHEN,DiZhi.MAO,DiZhi.YIN,DiZhi.CHOU,DiZhi.ZI,DiZhi.HAI};
	private static DiZhi[] wenQuBiao = {DiZhi.CHEN,DiZhi.SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU,DiZhi.HAI,DiZhi.ZI,DiZhi.CHOU,DiZhi.YIN,DiZhi.MAO};
	
	/**
	 * 根据出生时辰，返回文昌所在宫支
	 * @param shiChen 出生时辰
	 * @return DiZhi
	 */
	public static DiZhi anWenChang(DiZhi shiChen){
		return wenChangBiao[shiChen.ordinal()];
	}
	
	/**
	 * 根据出生时辰，返回文曲所在宫支
	 * @param shiChen 出生时辰
	 * @return DiZhi
	 */
	public static DiZhi anWenQu(DiZhi shiChen){
		return wenQuBiao[shiChen.ordinal()];
	}
	
	/**
	 * 地空和地劫是反应很大的星曜
	 * 亥宫起子时，顺数到生时安地劫，逆数到生时安地空。
	 */
	private static DiZhi[] diJieBiao = {DiZhi.HAI,DiZhi.ZI,DiZhi.CHOU,DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,DiZhi.SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU};
	private static DiZhi[] diKongBiao = {DiZhi.HAI,DiZhi.XU,DiZhi.YOU,DiZhi.SHEN,DiZhi.WEI,DiZhi.WU,DiZhi.SI,DiZhi.CHEN,DiZhi.MAO,DiZhi.YIN,DiZhi.CHOU,DiZhi.ZI};
	/**
	 * 根据出生时辰，返回地劫所在宫支
	 * @param shiChen 出生时辰
	 * @return DiZhi
	 */
	public static DiZhi anDiJie(DiZhi shiChen){
		return diJieBiao[shiChen.ordinal()];
	}
	
	/**
	 * 根据出生时辰，返回地空所在宫支
	 * @param shiChen 出生时辰
	 * @return DiZhi
	 */
	public static DiZhi anDiKong(DiZhi shiChen){
		return diKongBiao[shiChen.ordinal()];
	}	
	
	/**
	 * 台辅和封诰是吉祥的辅星
	 * 从午宫起子顺数到生时。如卯时生人，台辅在酉。
	 * 从寅宫起子时，顺数到生时。如卯时生人，封诰在巳宫。
	 */
	private static DiZhi[] taiFuBiao = {DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU,DiZhi.HAI,DiZhi.ZI,DiZhi.CHOU,DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,DiZhi.SI};
	private static DiZhi[] fengGaoBiao = {DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,DiZhi.SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU,DiZhi.HAI,DiZhi.ZI,DiZhi.CHOU};

	/**
	 * 根据出生时辰，返回台辅所在宫支
	 * @param shiChen 出生时辰
	 * @return DiZhi
	 */
	public static DiZhi anTaiFu(DiZhi shiChen){
		return taiFuBiao[shiChen.ordinal()];
	}
	
	/**
	 * 根据出生时辰，返回封诰所在宫支
	 * @param shiChen 出生时辰
	 * @return DiZhi
	 */
	public static DiZhi anFengGao(DiZhi shiChen){
		return fengGaoBiao[shiChen.ordinal()];
	}
}
